<template>
  <a-card :bordered="false" class="card-area">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="项目名称" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <a-input placeholder="请输入项目名称查询" v-model="queryParam.systemName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="机构" >
              <j-select-depart v-model="queryParam.office"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="创建时间" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <j-date v-model="queryParam.createTime" :showTime="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择创建时间" ></j-date>
            </a-form-item>
          </a-col>
          <a-col :md="6">

          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 操作按钮区域 -->
    <div class="table-operator"  style="margin-top: 5px">
      <!--        <a-button type="primary" style="margin-left: 5%" icon="download" @click="handleExportXls('台账记录')">导出</a-button>-->
      <!--        <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel" style="margin-left: 5%">-->
      <!--          <a-button type="primary"  icon="import">导入</a-button>-->
      <!--        </a-upload>-->
      <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
      <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
      <a-button type="primary" style="margin-left: 8px" @click="handleAdd" icon="plus">新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <cloud-apply-list-modal ref="modalForm" @ok="modalFormOk"></cloud-apply-list-modal>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">


        <span slot="action" slot-scope="text, record">
           <a @click="handleEdit(record)" >查看</a>
          <div style="width: 47px;display:inline-block" v-if="record.type=='2'">
            <a-divider type="vertical" />
            <a @click="handleEdit(record)">编辑</a>
          </div>
          <div style="width: 47px;display:inline-block" v-if="record.type=='0'">
            <a-divider type="vertical" />
             <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
          </div>

        </span>

      </a-table>
    </div>
    <!-- table区域-end -->


  </a-card>
</template>

<script>
  import cloudApplyListModal from './cloudApplyListModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  export default {
    name: 'cloudApplyList',
    mixins:[JeecgListMixin],
    components: {
        // RoleModal,
        cloudApplyListModal,
        JDate,
        JSelectDepart
    },
    data () {
        return {
            queryParam: {
                systemName:'',
                office:'',
                createTime:''
            },
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
            pagination: {
                total: 0,
                pageSize: 10,//每页中显示10条数据
                showSizeChanger: true,
                pageSizeOptions: ["10", "20", "50", "100"],//每页中显示的数据
                showTotal: total => `共有 ${total} 条数据`,  //分页中显示总的数据
            },
            columns:[
                {
                    title: '机构名称',
                    align:"center",
                    dataIndex: 'office_dictText'
                },
                {
                    title: '项目名称',
                    align:"center",
                    dataIndex: 'systemName'
                },
                {
                    title: '分配服务器地址',
                    align:"center",
                    dataIndex: 'outernetIp'
                },
                {
                    title: '申请服务器名称',
                    dataIndex: 'tos_dictText',
                    align:"center",
                },
              // {
              //   title: '申请配置',
              //   children: [
              //     {
              //       title: 'CPU(核)',
              //       dataIndex: 'applyCpu_dictText',
              //       align:"center",
              //       key: 'applyCpu',
              //       // width: 200,
              //     },
              //     {
              //       title: '内存(GB)',
              //       dataIndex: 'applyMemory',
              //       align:"center",
              //       key: 'applyMemory',
              //       // width: 200,
              //     },
              //     {
              //       title: '云硬盘(GB)',
              //       dataIndex: 'applyDisk',
              //       align:"center",
              //       key: 'applyDisk',
              //       // width: 200,
              //     },
              //   ],
              // },
              // {
              //   title: '建议部署配置',
              //   children: [
              //     {
              //       title: 'CPU(核)',
              //       dataIndex: 'cpu_dictText',
              //       align:"center",
              //       key: 'cpu',
              //       // width: 200,
              //     },
              //     {
              //       title: '内存(GB)',
              //       dataIndex: 'memory',
              //       align:"center",
              //       key: 'memory',
              //       // width: 200,
              //     },
              //     {
              //       title: '云硬盘(GB)',
              //       dataIndex: 'disk',
              //       align:"center",
              //       key: 'disk',
              //       // width: 200,
              //     },
              //   ],
              // },
                {
                    title: '费用',
                    dataIndex: 'cost',
                    align:"center",
                },

                {
                    title: '创建时间',
                    dataIndex: 'createTime',
                    align:"center",
                },
               {
                    title: '申请状态',
                    dataIndex: 'type',
                    align:"center",
                 customRender: (text) => {
                   let re = "";
                   if (text === '0') {
                     re = "等待审核";
                   } else if (text === '1') {
                     re = "审核通过";
                   }else if (text === '2') {
                     re = "审核未通过";
                   }
                   return re;
                 }
               },
                {
                    title:'操作',
                    dataIndex: 'action',
                    align:"center",
                    scopedSlots: { customRender: 'action' },
                }
            ],
            url: {
                list: "/jinan/standingBook/list",
                delete: "/jinan/standingBook/delete",
                // deleteBatch: "/sys/role/deleteBatch",
                exportXlsUrl: "/jinan/standingBook/exportXls",
              importExcelUrl: "jinan/standingBook/importExcel",

              // importExcelUrl: "sys/role/importExcel",
            },
        }
    },
    computed: {

      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
  }
</script>


<style scoped>
  @import '~@assets/less/common.less'
</style>